import random
import unittest
import ConfigParser

import sys
sys.path.append('..')

from lib.DBWrapper import DBWrapper
from db.QuoteAdapter import QuoteAdapter
from lib.Quote import Quote
from datetime import datetime

class QuoteAdapterTest(unittest.TestCase):

    def setUp(self):
        config = ConfigParser.ConfigParser()
        config.read('../cfg/config.cfg')        
        self.db = DBWrapper(config.get('Database', 'testdb'))

    def test_addquote(self):
        quote = QuoteAdapter(Quote(1, 3.14, 1, 10, 123, datetime.utcnow()))
        self.db.addQuote(quote)
        
        quotes = self.db.getQuotes() 
        self.assertIsNotNone(quotes)
        self.assertEqual(quotes[0].size, quote.size)
    

if __name__ == '__main__':
    unittest.main()